import Controller from "./Controller";
import {Request,Response} from 'express';
import killPort from 'kill-port'
class Port extends Controller
{
    constructor(req?:Request,res?:Response) {
        super(req,res);
    }

    /**
     * 停止模板运行的端口号  9288
     */
    stopPort() {
        try {
            const port = 9288;
            killPort(port) 
                .then(() => {
                    this.response(200);
                })
                .catch((error) => {
                    throw new Error("端口号关闭失败")
                })
        }catch(error:any) {
            this.response(error.code?error.code:402,[],error.message)
        }
    }
}

export default Port;